//
//  LCMineAdvertTableViewCell.m
//  lechuang
//
//  Created by Mr_hi on 2023/3/28.
//  Copyright © 2023 Mooyi. All rights reserved.
//

#import "LCMineAdvertTableViewCell.h"
#import "LCCouponAdvertModel.h"

@interface LCMineAdvertTableViewCell ()

@property (weak, nonatomic) IBOutlet UIView *inviteAdView;

@property (weak, nonatomic) IBOutlet UIImageView *oneAdView;

@property (weak, nonatomic) IBOutlet UIView *taskAdView;

@property (weak, nonatomic) IBOutlet UIImageView *twoAdView;

@end


@implementation LCMineAdvertTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.inviteAdView whenTapped:^{
        if (self.clickAction) {
            self.clickAction(@"邀请好友");
        }
    }];
    [self.taskAdView whenTapped:^{
        if (self.clickAction) {
            self.clickAction(@"领现金好礼");
        }
    }];
}

-(void)setAdvertArr:(NSMutableArray *)advertArr {
    _advertArr = advertArr;
    if ([advertArr.firstObject isKindOfClass:[LCCouponAdvertModel class]]) {
        LCCouponAdvertModel * oneAd = advertArr.firstObject;
        [self.oneAdView sd_setImageWithURL:[LCFunction XWX_URLImg:oneAd.strimage]];
        [self.inviteAdView whenTapped:^{
            if (self.clickAction) {
                if ([NSString urlValidation:oneAd.strlinks]) {
                    self.clickAction(oneAd.strlinks);
                } else {
                    self.clickAction(@"邀请好友");
                }
            }
        }];
    }
    
    if ([advertArr.lastObject isKindOfClass:[LCCouponAdvertModel class]]) {
        LCCouponAdvertModel * twoAd = advertArr.lastObject;
        [self.twoAdView sd_setImageWithURL:[LCFunction XWX_URLImg:twoAd.strimage]];
        [self.taskAdView whenTapped:^{
            if (self.clickAction) {
                if ([NSString urlValidation:twoAd.strlinks]) {
                    self.clickAction(twoAd.strlinks);
                } else {
                    self.clickAction(@"领现金好礼");
                }
            }
        }];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
